package com.xmg.p2p.business.service.impl;

import com.xmg.p2p.base.query.PageResult;
import com.xmg.p2p.business.domain.PlatformBankinfo;
import com.xmg.p2p.business.mapper.PlatformBankinfoMapper;
import com.xmg.p2p.business.query.PlatformBankinfoQueryObject;
import com.xmg.p2p.business.service.IPlatformBankinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: jinrong-website
 * @BelongsPackage: com.xmg.p2p.business.service.impl
 * @author: Andy
 * @date: 2021.4.7 19:22
 * @Description: 实现类
 * @since JDK 1.8
 */
@Service
public class PlatformBankinfoServiceImpl implements IPlatformBankinfoService {
    @Autowired
    private PlatformBankinfoMapper platformBankinfoMapper;
    //分页操作
    public PageResult
    query(PlatformBankinfoQueryObject qo) {
        int count = this.platformBankinfoMapper.queryForCount(qo);
        if (count > 0) {
            List<PlatformBankinfo> list = this.platformBankinfoMapper.query(qo);
            return new PageResult(list, count, qo.getCurrentPage(), qo.getPageSize());
        }
        return PageResult.empty(qo.getPageSize());
    }
    /**
     * 账户的保存或者更新
     */
    public void saveOrUpdate(PlatformBankinfo platformBankinfo) {
        if (platformBankinfo.getId() != null) { //更新操作
            this.platformBankinfoMapper.updateByPrimaryKey(platformBankinfo);
        }else{
            this.platformBankinfoMapper.insert(platformBankinfo);
        }
    }
    //获取所有
    public List<PlatformBankinfo> listAll() {
        return this.platformBankinfoMapper.selectAll();
    }
}
